﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BaddiesEditor.Events;

namespace BaddiesEditor.CustomComponent
{
    /// <summary>
    /// Form used to save a project.
    /// </summary>
    public partial class SaveForm : Form
    {
        /// <summary>
        /// Event handler for when we click the save button.
        /// </summary>
        private EventHandler saveHandler;

        /// <summary>
        /// Initializes a new instance of the SaveForm class.
        /// </summary>
        /// <param name="currentMapName"> Current name of the project, so the save has a default name.</param>
        /// <param name="saveHandler"> Event handler for when the user clicks save. Use it to check the final name of the save.</param>
        public SaveForm(string currentMapName, EventHandler saveHandler)
        {
            this.InitializeComponent();
            this.nameTextBox.Text = currentMapName;
            this.saveHandler += saveHandler;
        }

        /// <summary>
        /// Called when the label is clicked.
        /// </summary>
        /// <param name="sender"> Class that calls the handler.</param>
        /// <param name="e"> Arguments of the call.</param>
        private void Label1_Click(object sender, EventArgs e)
        {
        }

        /// <summary>
        /// Called when the cancel button is clicked.
        /// </summary>
        /// <param name="sender"> Class that calls the handler.</param>
        /// <param name="e"> Arguments of the call.</param>
        private void CancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// Called when the save button is clicked.
        /// </summary>
        /// <param name="sender"> Class that calls the handler.</param>
        /// <param name="e"> Arguments of the call.</param>
        private void SaveButton_Click(object sender, EventArgs e)
        {
            this.Close();

            this.saveHandler(this, new SaveMapArg(this.nameTextBox.Text));
        }
    }
}
